package cn.wolfcode.qo;

import cn.wolfcode.domain.Department;
import lombok.Getter;
import lombok.Setter;

import java.util.List;
@Getter
@Setter
public class PageResult<T> extends QueryObject {
    private int totalCount;
    private List<T> date;

    private int currentPage;
    private int pageSize;

    private int totalPage;
    private int prevPage;
    private int nextPage;

    public PageResult(int totalCount, List<T> date, int currentPage, int size) {
        this.totalCount = totalCount;
        this.date = date;
        this.currentPage = currentPage;
        this.pageSize = size;
        this.totalPage = this.totalCount % this.pageSize == 0 ? (this.totalCount / this.pageSize) : ((this.totalCount / this.pageSize) + 1);
        this.prevPage = this.currentPage - 1 <= 1 ? 1 : currentPage - 1;
        this.nextPage = currentPage + 1 > totalPage ? totalPage : currentPage + 1;
    }
}
